<?php
	require 'config.php';
	$title = '联系方式 - www.cblit.com的联系方式';
	$notice = 0;
	if($_POST['fsubmit']=="Submit")
	{
		foreach($_POST as &$val)
		{
			$val = doStrings($val);
		}
		extract($_POST);
		if($fsub==4 && $fmessage && $fmail)
		{
			$notice = $_->message->submit(array('name'=>$fname,'email'=>$fmail,'web'=>$fweb,'message'=>$fmessage,'ip'=>getIP()));
			$notice > 1 ? cookie(array('contact'=>urlencode(json_encode($_POST))),$time = 3600,$domain=".one.dev"):cookie(array('contact'=>null),$time = 3600,$domain=".one.dev");
		}else{
			cookie(array('contact'=>urlencode(json_encode($_POST))),$time = 3600,$domain=".one.dev");
			$notice = 2;
		}
		$ms = array(
			'1'=>'消息提交成功，我们将在第一时间联系你。',
			'2'=>'消息验证失败',
			'3'=>'消息已提交，请勿重复提交',
			'4'=>'今天提交的信息较多，请明天再来',
			'5'=>'由于网络原因，消息提交失败.'
		);
		_redirect($ms[$notice],'/contact.php');exit;
	}
	$post = (array)json_decode(urldecode($_COOKIE['contact']));
	$smarty->_assign(array('title','post'));
	$smarty->_display();
?>